﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Xml;
using System.Text;

namespace XWeb.Code
{
    public class XMLHelper
    {
        public static string ListParseToXML<T>(List<T> obj)
        {
            string strXML = "";
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(List<T>));
            {
                MemoryStream memoryStream = new MemoryStream();
                XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
                xs.Serialize(xmlTextWriter, obj);
                strXML = Encoding.UTF8.GetString(memoryStream.ToArray());
                memoryStream.Close();
            }
            return strXML;
        }
    }
}